package IO;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;

/**
 * Properties
 * @author hai
 *
 */
public class PropertiesTest {

	/**
	 * @param args
	 */
	@SuppressWarnings("rawtypes")
	public static void main(String[] args) {
				File file = new File("E:\\Hai\\as\\src\\ad.properties");
				try {
					FileInputStream inputStream = new FileInputStream(file);
					Properties properties = new Properties();
					properties.load(inputStream);
					properties.getProperty("");
//					Enumeration e = properties.keys();
//					while(e.hasMoreElements()){
//						System.out.println(e.nextElement());
//					}
					System.out.println(properties.getProperty("ass"));
					FileOutputStream os = new FileOutputStream(file);
					properties.setProperty("a", "1");
					properties.store(os, "");
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
//				Enumeration enumeration =  properties.keys();
//				while (enumeration.hasMoreElements()) {
//					System.out.println(enumeration.nextElement());
//				}
//				properties.put("d", "2");
//				FileOutputStream outputStream = new FileOutputStream(file);
//				properties.store(outputStream, "");
//				outputStream.flush();
//				outputStream.close();
//				properties.setProperty("adf", "1");
//				properties.store(outputStream, "");
	}

}
